package main

import (
	"context"
	"fmt"
	protoExample "golang-grpc-example/cilent/proto"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"time"
)

func main() {
	// 连接服务端
	conn, _ := grpc.Dial("127.0.0.1:9090", grpc.WithTransportCredentials(insecure.NewCredentials()))
	defer conn.Close()
	// 创建客户端
	client := protoExample.NewExampleClient(conn)
	// 发送rpc请求
	now := time.Now()
	dateString := now.Format("2006-01-02 15:04:05")
	resp, _ := client.ExampleFunc(context.Background(), &protoExample.ExampleRequest{RequestName: fmt.Sprintf("%s send grpc call", dateString)})
	// 输出结果
	fmt.Println(resp.GetResponseMsg())
}
